<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no"/>
    <title>管理后台</title>
    <link rel="stylesheet/less" href="../../../static/css/index.less"/>
    <link rel="stylesheet" href="../../../static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../../static/css/jquery.pagination.css"/>
    <script src="../../../static/js/jquery-1.12.3.js"></script>
    <script src="../../../static/js/less.min.js"></script>
    <script src="../../../static/layui/layui.js"></script>
    <script src="../../../static/js/ajaxfileupload.js"></script>
    <script src="../../../static/layer/layer.js"></script>
    <SCRIPT language=javascript src="../../static/layer/layer.js"></SCRIPT>
</head>
<style>

</style>
<body class="layui-layout-body">

{% include "/admin/top.html" %}
{% include "/admin/left.html" %}


<div id="box" class="fl clearfix">
    <div class="content" style="height: 100%">
        <h3 style="color:  #3D89CB">管理员列表</h3>
        <div class="h30">
            <button class="s_button clearfix"
                    style="color: white;background-color: #3D89CB;margin-left: 100px ;float: left"
                    onclick='location.href="/admin/route/newly.html"'>
                新增路由
            </button>
            <button class="s_button clearfix"
                    style="color: white;background-color: #3D89CB;margin-right: 100px ;float: right"
                    onclick='location.href="/admin/manage/newly.html"'>
                新增
            </button>
        </div>
        <table width="100%" border="0" cellspacing="0" cellpadding="0">
            <thead>
            <tr>
                <th width="10%">管理员ID</th>
                <th width="12%">管理员账号</th>
                <th width="10%">管理员类型</th>
                <th width="10%">创建时间</th>
                <th width="10%">状态</th>
                <th width="20%">操作</th>
            </tr>
            </thead>

            <tbody>
            {% if res['code']==400 %}
                <tr class="color2">
                    <td colspan=8 align="center">暂无数据</td>
                </tr>
            {% elif res['code']==200 %}
                {% for data in res['data'] %}

                    <tr>
                        <td>{{ data.uid }}</td>
                        <td>{{ data.username }}</td>
                        <td>{{ data.user_type_name }}</td>
                        <td>{{ data.create_time }}</td>
                        <td>
                            {% if data.status == 1 %}
                                激活状态
                            {% elif data.status == 0 %}
                                禁用
                            {% endif %}
                        </td>
                        <td>
                            <button><span style="color: green"><a
                                    href="/admin/manage/power.html?uid={{ data.uid }}">权限</a></span>
                            </button>
                            {% if data.status == 1 %}
                                <button class="ccc">
                                    <a href="#" onclick="stop({{ data.uid }})">禁用</a>
                                </button>
                            {% elif data.status == 0 %}
                                <button class="green">
                                    <a href="#" onclick="member({{ data.uid }})">激活</a>
                                </button>
                            {% endif %}
                            <button class="red"><a href="#" onclick="delete_admin({{ data.uid }})">删除</a>
                            </button>
                        </td>
                    </tr>
                {% endfor %}
            {% endif %}


            </tbody>
        </table>


    </div>
</div>
</div>

</body>
</html>

<script>


    function stop(uid) {
        layer.open({
            content: '你确定禁用',
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function () {
                $.ajax({
                    url: '/admin/manage/stop',
                    type: 'post',
                    data: {
                        'uid': uid
                    },
                    dataType: 'json',
                    success: function (msg) {
                        if (msg.status == 1) {
                            layer.msg("操作成功！", {time: 2000}, function () {
                                window.location.href = location.pathname;
                            });


                        } else {
                            layer.msg("操作失败！");
                        }
                    }
                });
            }
        });
    }

    function member(uid) {
        layer.open({
            content: '你确定激活',
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function () {
                $.ajax({
                    url: '/admin/manage/start',
                    type: 'post',
                    data: {
                        'uid': uid
                    },
                    dataType: 'json',
                    success: function (msg) {
                        if (msg.status == 1) {
                            layer.msg("操作成功！", {time: 2000}, function () {
                                window.location.href = location.pathname;
                            });


                        } else {
                            layer.msg("操作失败！");
                        }
                    }
                });
            }
        });
    }
    function delete_admin(uid) {
        layer.open({
            content: '你确定删除',
            btn: ['确认', '取消'],
            shadeClose: false,
            yes: function () {
                $.ajax({
                    url: '/admin/manage/delete',
                    type: 'post',
                    data: {
                        'uid': uid
                    },
                    dataType: 'json',
                    success: function (msg) {
                        if (msg.status == 1) {
                            layer.msg("操作成功！", {time: 2000}, function () {
                                window.location.href = location.pathname;
                            });


                        } else {
                            layer.msg("操作失败！");
                        }
                    }
                });
            }
        });
    }
</script>


